package com.wlr.study.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicInteger;

public class TransportService {
    public String test1() {
        return "sss";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        List<FutureTask<Integer>> tasks = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            FutureTask<Integer> stringFutureTask = new FutureTask<>(new TestTask("任务" + i, (i+1)*10));
            tasks.add(stringFutureTask);
            executorService.submit(stringFutureTask);
        }
        for (FutureTask<Integer> task : tasks) {
            task.get();
        }
        executorService.shutdown();
    }
}
